<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<script src="lib/jsonp.js"></script>
</head>
<body>
    <button>点我</button>
    <input type="text">
	<div id="search"></div>
</body>
<!--<script>-->
<!--	function my(data){-->
<!--		console.log(data);-->
<!--	}-->
<!--	function abc(data){-->
<!--		console.log(data);-->
<!--	}-->
<!--</script>-->
<!--<script src="https://wq.360buyimg.com/data/coss/keyword/project/mpj1715.jsonp?callback=pj1715"></script>-->
<!--<script src="https://www.baidu.com/sugrec?prod=pc&wd=芝加哥&cb=abc"></script>-->

<script>
	document.querySelector("button").onclick = function(){
		jsonp("https://wq.360buyimg.com/data/coss/keyword/project/mpj1715.jsonp",{
			jsonp:"callback",
			fnName:"pj1715"
		}).then(value=>{
			console.log(value)
		})
	}
	const search = document.querySelector("#search")
	document.querySelector("input").onkeyup = function(){
		jsonp("https://www.baidu.com/sugrec",{
			params:{
				prod:"pc",
				wd:this.value,
			},
			jsonp:"cb"
		}).then(value=>{
			console.log(value.g);
			if(value.g instanceof Array){
				search.innerHTML = value.g.map(item=>`
				<p>${item.q}</p>
			`).join("");
			}else{
				search.innerHTML = "";
			}
			
		})
	}
	
	
</script>
</html>